<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/3/27
  Time: 15:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>增加管理员</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content=" ">
    <meta name="description" content=" ">
    <meta name="author" content="yinqi">
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <form method="post" class="site-form">
                        <div class="form-group">
                            <label for="name">登录名</label>
                            <input type="text" class="form-control" name="name" id="name" placeholder="输入登录名">
                        </div>
                        <div class="form-group">
                            <label for="pwd">密码</label>
                            <input type="password" class="form-control" name="pwd" id="pwd" placeholder="输入密码">
                        </div>
                        <div class="form-group">
                            <label for="repwd">确认密码</label>
                            <input type="password" class="form-control" name="repwd" id="repwd" placeholder="请确认密码">
                        </div>
                        <div class="form-group">
                            <label for="email">邮箱</label>
                            <input type="text" class="form-control" name="email" id="email" value="" placeholder="请输入邮箱"/>
                        </div>
                        <button type="button" class="btn btn-primary" style="margin-top: 10px" onclick="add()">保存</button>
                    </form>
                </div>
            </div>
        </div>

    </div>

</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/main.min.js"></script>
<script>
    function add() {
        var name=$("#name").val();
        var pwd=$("#pwd").val();
        var repwd=$("#repwd").val();
        var email=$("#email").val();
        // var userData = $("#userForm").serialize();
        if (name == "") {
            alert("请输入登录名！");
            return;
        }
        if (pwd==""){
            alert("请输入密码！");
            return;
        }
        if (pwd != repwd) {
            alert("两次密码不一致！");
            return;
        }
        if (email==""){
            alert("请输入邮箱！");
            return;
        }

        $.ajax({
            url :  "${pageContext.servletContext.contextPath}/admin/addpost",
            data:{"name":name,"pwd":pwd,"email":email},
            // data : userData,
            type : "post",
            success : function (msg) {
                alert("保存成功");
                top.location.href="${pageContext.request.contextPath}/admin/main";
            }
        });

    }
</script>
</body>
</html>
